Using the Level of Detail node
Use the Level of Detail node when you want to show different appearances of the same object, or different object, based on the viewing distance of the Level of Detail node. Each child of a Level of Detail node sets a single appearance and a constraint when that appearance is selected and shown. The constraint can be either:
- Minimum distance from the preview camera. You set the constraint by setting the value of the Minimum Distance property. Lower values set the child node to be selected when the preview camera is closer to the object. Higher values set the child node to be selected when the preview camera is further away from the object. Kanzi shows the child whose distance value is the next largest compared to the Level of Detail node's distance to the preview camera.
- Minimum coverage of the screen. You set the constraint by setting the value of the Minimum Area property. The coverage of the screen is measured in range [0...10], where 0 means that the object does not cover the screen at all, and 10 means that the object completely covers the screen. Kanzi shows the child whose area value is the next largest compared to the Level of Detail node's bounding box projection area to the screen.
Note that the Level of Detail nodes affect only rendering, which is why you cannot use them in layouts. The size of the Level of Detail node is the size of its largest child, even if that child is not visible at the current Level of Detail node.
Creating a Level of Detail node
To create a Level of Detail node:
- In the Project press Alt and right-click the node where you want to create a Level of Detail node and select Level of Detail.
Note that you create Level of Detail only inside 3D nodes.
- In the Properties set the Type property to either:
- Distance to create a Level of Detail node that shows its child nodes based on Level of Detail node's distance from the preview camera.
- Perspective to create a level of detail that shows its child nodes whose area value is the next largest compared to the Level of Detail node's bounding box projection area to the screen.
For example, set Type to Distance.
- In the Project add child nodes to the Level of Detail node.
For example, add a Sphere, a Box, and a Plane node.
For each item you add to the Level of Detail node, based on the type of Level of Detail node you selected, Kanzi Studio adds either the Minimum Distance or Minimum Area property.
- Select each node you added to the Level of Detail node and in the Properties, depending on the Level of Detail node you selected, set either the Minimum Distance or Minimum Area property value to define when the Level of Detail node shows each item.
For example, if you set Type to Distance, in the Project select:- Sphere and set its Minimum Distance property to 0.
- Box and set its Minimum Distance property to 10.
- Plane and set its Minimum Distance property 20.
When you move the Level of Detail node or the preview camera along the z axis, Kanzi shows the child node whose distance value is the next largest compared to the Level of Detail node’s distance to the preview camera.
Using the Level of Detail node in the API
To create a distance level of detail selector node with three levels of detail:
// Create a level of detail selector node named LOD selector.
LevelOfDetail3DSharedPtr lodSelector = LevelOfDetail3D::create(domain, "LOD selector");
// Add three levels of detail, one child for each level.
lodSelector->addChild(lodHigh);
lodSelector->addChild(lodMedium);
lodSelector->addChild(lodLow);
// Set the level of detail selector node to show its child objects based on the
// level of detail selector node's distance from the preview camera.
lodSelector->setType(LevelOfDetail3D::LodTypeDistance);
// Use low level of distance child (lodLow) when the preview camera distance is
// at least 10.0f.
LevelOfDetail3D::setMinimumDistance(*lodLow, 10.0f);
// Use medium level of distance child (lodMedium) when the preview camera distance
// is at least 5.0f, but less than 10.0f.
LevelOfDetail3D::setMinimumDistance(*lodMedium, 5.0f);
// Use high level of distance child (lodHigh) when preview camera distance is
// less than 5.0f.
LevelOfDetail3D::setMinimumDistance(*lodHigh, 0.0f);
For details, see the LevelOfDetail3D
class in the API reference.
Level of Detail property types and messages
For a list of the available property types and messages for the Level of Detail node, see Level of detail.
See also
Using the Empty Node nodes
Open topic with navigation